{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "25cd0bc2",
   "metadata": {},
   "source": [
    "黄柏睿的学习"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "9f86d1ae",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "0\n",
      "1\n",
      "2\n",
      "3\n",
      "4\n"
     ]
    }
   ],
   "source": [
    "for i in range(5):\n",
    "    print(i)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "f5f2d57a",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "range(0, 5)"
      ]
     },
     "execution_count": 2,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "# 创建有序数值（创建自然数）\n",
    "range(5)  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "id": "993cfafa",
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[0, 1, 2, 3, 4]"
      ]
     },
     "execution_count": 3,
     "metadata": {},
     "output_type": "execute_result"
    }
   ],
   "source": [
    "list(range(0,5))  # 产生了  5-0 个值 ， 默认从0开始  注：0（start）  5（stop）  每一次增长 1 个单位"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "id": "eb1ac57e",
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "https://www.nfu.edu.cn/xxyw/index0.htm\n",
      "该次停留 7 秒\n",
      "https://www.nfu.edu.cn/xxyw/index1.htm\n",
      "该次停留 3 秒\n",
      "https://www.nfu.edu.cn/xxyw/index2.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index3.htm\n",
      "该次停留 2 秒\n",
      "https://www.nfu.edu.cn/xxyw/index4.htm\n",
      "该次停留 3 秒\n"
     ]
    }
   ],
   "source": [
    "### 实战练习: 快速生成 某个网站的所有页码的URL队列\n",
    "import random\n",
    "import time\n",
    "南方学院学校要闻 = \"https://www.nfu.edu.cn/xxyw/index\"\n",
    "页面后缀 = \".htm\"\n",
    "page = 5\n",
    "for i in range(page):\n",
    "    print(南方学院学校要闻 + str(i) + 页面后缀)  # 字符串拼接\n",
    "    random_num = random.randint(1,10)\n",
    "    print(\"该次停留\",random_num,'秒')\n",
    "    time.sleep(random_num)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "id": "4e10de9a",
   "metadata": {},
   "outputs": [
    {
     "ename": "SyntaxError",
     "evalue": "invalid syntax (1126856005.py, line 1)",
     "output_type": "error",
     "traceback": [
      "\u001b[1;36m  Input \u001b[1;32mIn [1]\u001b[1;36m\u001b[0m\n\u001b[1;33m    项目3 P44\u001b[0m\n\u001b[1;37m        ^\u001b[0m\n\u001b[1;31mSyntaxError\u001b[0m\u001b[1;31m:\u001b[0m invalid syntax\n"
     ]
    }
   ],
   "source": [
    " 项目3 P44\n",
    "\n",
    "word = \"bottles\"\n",
    "\n",
    "for beer_num in range(99,0,-1):\n",
    "    print(beer_num,word,\"在啤酒墙上~~\")\n",
    "    print(beer_num,word,\"啤酒~~\")\n",
    "    print(\"拿一瓶走~~\")\n",
    "    if beer_num == 1:\n",
    "        print(\"只剩一瓶了，不能给你了！\")\n",
    "    else:\n",
    "        new_num = beer_num - 1\n",
    "        if new_num == 1:\n",
    "            word = \"bottle\"\n",
    "        print(new_num,word,\"在啤酒墙上\")\n",
    "    print()\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "db86d23a",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3 (ipykernel)",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.9.12"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
